package abstractionsLesson.tictactoe;

public class PlayerAI extends APlayer {
	
	String name = "AI";
	@Override
	void makeTurn(char[][] f) {
		if (f[1][1] == 0) {
			f[1][1] = 'O';
			return;
		} else {
			for (int i = 0; i < 3; i++) {
				if (i != 1 && f[i][2 - i] == f[1][1] && f[2 - i][i] == 0) {
					f[2 - i][i] = 'O';
					return;
				} else if (i != 1 && f[i][i] == f[1][1] && f[2 - i][2 - i] == 0) {
					f[2 - i][2 - i] = 'O';
					return;
				} else if (f[i][0] == f[i][1] && f[i][0] != 0 && f[i][2] == 0) {
					f[i][2] = 'O';
					return;
				} else if (f[i][0] == f[i][2] && f[i][0] != 0 && f[i][1] == 0) {
					f[i][1] = 'O';
					return;
				} else if (f[i][1] == f[i][2] && f[i][1] != 0 && f[i][0] == 0) {
					f[i][0] = 'O';
					return;
				} else if (f[0][i] == f[1][i] && f[0][i] != 0 && f[2][i] == 0) {
					f[2][i] = 'O';
					return;
				} else if (f[1][i] == f[2][i] && f[1][i] != 0 && f[0][i] == 0) {
					f[0][i] = 'O';
					return;
				} else if (f[0][i] == f[2][i] && f[0][i] != 0 && f[1][i] == 0) {
					f[1][i] = 'O';
					return;
				}

			}
			for (int i = 0; i < 3; i++) {
				if (f[i][i] == 0) {
					f[i][i] = 'O';
					return;
				} else if (f[i][2 - i] == 0) {
					f[i][2 - i] = 'O';
					return;
				}
			}
		}
	}

	@Override
	String getName() {
		return "AI";
	}

	@Override
	void setName() {
		// TODO Auto-generated method stub
		
	}

	@Override
	char getMark() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	void setMark() {
		// TODO Auto-generated method stub
		
	}

}
